<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<script>
    function sum(x, y, z) {
        let total = 0;
        if (x) total += x;
        if (y) total += y;
        if (z) total += z;
        console.log(`total:${total}`)
    }

    sum(3, 6, 9);

    function sum2(...m) {
        let total = 0;
        for (var i of m) {
            total += i;
        }
        console.log(`total:${total}`)
    }

    sum2(3, 6, 9, 11);

    let sum3 = (...m) => {
        let total = 0;
        for (var i of m) {
            total += i;
        }
        console.log(`total:${total}`)
    }
    sum3(33, 6, 9, 11);

    var [x, y] = [4, 7];

    console.log(...[4, 8]);

    let arr1 = [1, 3];
    let arr2 = [2, 4];

    console.log([...arr1, ...arr2]); //合并数组

    let [a, b, c] = ['ES6']; //a='E',B='S',c='6'

    let xy = [...'es6'] //xy =['e','s','6']
    console.log(xy);
</script>
</body>
</html>